﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Common;

namespace ElectrosLtdApplication.Controllers
{
    public class MenusController : Controller
    {
        //
        // GET: /Menus/

        /*public ActionResult Index()
        {
            return View();
        }*/

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (Request.IsAuthenticated)
            {
                ViewBag.Menus = new MenusServ.MenusServiceClient().GetMainMenusByUsername(HttpContext.User.Identity.Name);
                // = menus;
                //List<Menu> submenus = new List<Menu>();
                /*foreach (Menu m in ViewBag.Menus)
                {
                    int id = m.ParentID;
                    if (id != 1)
                    {
                        ViewBag.Submenus = new MenusServ.MenusServiceClient().GetSubmenusByUsername(HttpContext.User.Identity.Name, id).ToList();
                    }
                }*/
                //ViewBag.Submenus = submenus;
            }
            else
            {
                ViewBag.Menus = new MenusServ.MenusServiceClient().GetMainMenusByID(3);
                // = menus;
                //List<Menu> submenus = new List<Menu>();
                /*foreach (Menu m in ViewBag.Menus)
                {
                    int id = m.ParentID;
                    if (id != 1)
                    {
                        ViewBag.Submenus = new MenusServ.MenusServiceClient().GetSubmenusByID(3, id).ToList();
                    }

                }*/
                //ViewBag.Submenus = submenus;
            }
            base.OnActionExecuting(filterContext);
        }
    }
}
